package com.zhl.media.app.utils;

import android.content.Context;

import com.zhl.media.app.greendao.AdJustDao;
import com.zhl.media.app.greendao.ElevatorDao;
import com.zhl.media.app.greendao.MediaPhotoDao;
import com.zhl.media.app.greendao.MediaPositionDao;
import com.zhl.media.app.greendao.ProjDao;


public class EntityManager {

    private static EntityManager entityManager;

    private Context context;

    public EntityManager(Context context) {

        this.context = context;
    }

    public MediaPhotoDao mediaPhotoDao;


    public ProjDao projDao;

    public MediaPositionDao mediaPositionDao;

    public ElevatorDao elevatorDao;

    public AdJustDao adJustDao;

    public AdJustDao getAdJustDao() {
        if(adJustDao==null){
            adJustDao = DaoManager.getInstance(context).getSession().getAdJustDao();
        }
        return adJustDao;
    }

    public MediaPositionDao getMediaPositionDao() {
        if(mediaPositionDao==null){
            mediaPositionDao = DaoManager.getInstance(context).getSession().getMediaPositionDao();
        }
        return mediaPositionDao;
    }

    public ElevatorDao getElevatorDao() {
        if(elevatorDao==null) {
            elevatorDao = DaoManager.getInstance(context).getSession().getElevatorDao();
        }
        return elevatorDao;
    }

    public MediaPhotoDao getMediaPhotoDao(){
        if(mediaPhotoDao==null) {
            mediaPhotoDao = DaoManager.getInstance(context).getSession().getMediaPhotoDao();
        }
        return mediaPhotoDao;
    }


    public ProjDao getProjDao() {
        if (projDao == null) {
            projDao = DaoManager.getInstance(context).getSession().getProjDao();
        }
        return projDao;
    }

    /**
     * 创建单例
     * @return
     */
    public static EntityManager getInstance(Context context) {
        if (entityManager == null) {
            entityManager = new EntityManager(context);
        }
        return entityManager;
    }
}